#!/usr/bin/env bash

help(){
    cat<<__EOF__
Usage: m audio [OPTIONS]

Description: Manage audio settings on macOS.


Options:
  --help            Show this help message
  --reset [hard]    Reset audio settings (pass 'hard' to restart coreaudiod service)
__EOF__
}

reset(){
    if [ "${1}" == "hard" ]; then
        sudo launchctl stop com.apple.audio.coreaudiod
        sudo launchctl start com.apple.audio.coreaudiod
    else
        sudo killall coreaudiod
    fi
}

case $1 in
    --help)
        help
        ;;
    --reset)
        shift
        reset "${@}"
        ;;
    *)
        help
        ;;
esac
